﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Diagnostics;

namespace PRET.DBAdapter
{
    public class LogRecord
    {
        private readonly static string LogSource = "PRETLogSource";
        private readonly static string LogName = "PRETLog";

        public static void Error(string message)
        {
            EventLog eventLog = null;
            if (!(EventLog.SourceExists(LogSource)))
                EventLog.CreateEventSource(LogSource, LogName);
            if (eventLog == null)
            {
                eventLog = new EventLog(LogName);
                eventLog.Source = LogSource;
            }
            eventLog.WriteEntry(message, EventLogEntryType.Error);
        }
        public static void Warning(string message)
        {
            EventLog eventLog = null;
            if (!(EventLog.SourceExists(LogSource)))
            {
                EventLog.CreateEventSource(LogSource, LogName);
            }
            if (eventLog == null)
            {
                eventLog = new EventLog(LogName);
                eventLog.Source = LogSource;
            }
            eventLog.WriteEntry(message, System.Diagnostics.EventLogEntryType.Warning);
        } 
    }
}
